package Object;

import java.io.IOException;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

public class MyObjectOutputStream {
    public static void main(String[] args) {
        try(//先创建一个低级输出流
            OutputStream os = new FileOutputStream("D:\\software\\code\\2023_java\\2023_java_code\\code_24_4_26\\src\\Object\\ObjectText");
            //创建序列化流
            ObjectOutputStream oos = new ObjectOutputStream(os);
            ){
            //将用户对象写入到文件中
            User user = new User("小蜜蜂","001",18,"123456");
            oos.writeObject(user);
            System.out.println("序列化创建成功!!!");
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}
